// Parses XML representations of Snap! objects

function parse(xml, refs) {
    switch (xml.nodeName) {
        case "l": {
            return xml.textContent;
        }

        case "list": {
            var arr = list.children.map(v => {
                if (v.nodeName !== "item") throw new Error("Expected <item> tag");
                return parse(v.firstChild, refs);
            });

            refs.set(xml.attributes.id.nodeValue, arr);
            return arr;
        }
    }
}